module.exports = {
	computed: {},
	methods: {
		goPage(url,auth=false) {
			if(auth && !this.vuex_token){
				this.$cu.toast('请先登录');
				return;
			}
			if (url.indexOf('http') === 0) {
				return window.open(url);
			}
			// url 开头可用有 / ，也可没有
			if (url[0] !== '/' && url.indexOf('http') !== 0) {
				url = '/' + url;
			}
			uni.navigateTo({
				url: url,
				fail: () => {
					uni.showModal({
						title: '提示',
						content: '页面 ' + url + ' 跳转失败',
						showCancel: false
					});
				}
			});
		},
		//登录、注册成功
		success(res, index = 1) {
			this.$vuex('vuex_token', res.token);
			uni.setStorageSync('uni_id_token', res.token)
			uni.setStorageSync('uni_id_token_expired', res.tokenExpired);
			setTimeout(() => {
				uni.navigateBack({
					delta: index
				});
			}, 1500)
		},
		getPhotosIndex(callback=()=>{}){
			// #ifndef MP-WEIXIN
			const app = getApp();
			// #endif
			// #ifdef MP-WEIXIN
			const app = getApp().$vm;
			// #endif
			if(!this.id && !this.pid){
				this.$cu.toast('相册参数不能为空',()=>{
					uni.navigateBack({
						delta:1
					})
				})
				return;
			}
			this.$api.getPhotosIndex({id:this.id,pid:this.pid}).then(({code,data,message})=>{
				if(!code){
					this.info = data;
					if(data.bg_music){
						app.src = data.bg_music;
					}
				}else{
					this.$cu.toast(message,()=>{
						uni.navigateBack({
							delta:1
						})
					});
				}
				callback()
			})
		}
	}
}
